package com.jlnk.androidfmc.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import androidx.fragment.app.Fragment;

import com.jlnk.androidfmc.R;
import com.jlnk.androidfmc.fragment.fragments.SellerHomeFragment;
import com.jlnk.androidfmc.view.SellerFooterView;

public class SellerFragment extends Fragment {

    private SellerFooterView sellerFooterView;
    private FrameLayout fragmentContainer;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_seller, container, false);

        // Initialize the footer view and container
        sellerFooterView = view.findViewById(R.id.seller_footer_view);
        fragmentContainer = view.findViewById(R.id.fragment_container);

        // Setup footer view with this fragment's FragmentManager
        sellerFooterView.setupWithFragmentManager(getChildFragmentManager());

        // Load the initial fragment
        loadFragment(new SellerHomeFragment());

        return view;
    }

    private void loadFragment(Fragment fragment) {
        if (fragment != null) {
            getChildFragmentManager().beginTransaction()
                    .replace(R.id.fragment_container, fragment)
                    .commit();
        }
    }
}